# import requests
#
#
# from util.get_header import *
# url = 'https://api.bilibili.com/x/web-interface/wbi/index/top/feed/rcmd?&brush=3&ps=10'
#
# response = requests.get(url, headers=get_headers_init_user_agent())
# # print(response.text)
# # print(response.content.decode('utf-8'))
#
# data = response.json()
# print(data)


import requests
import time
from util.get_header import get_headers_init_referer
from util.get_time_stamp import get_time_stamp
import json




url = f'https://product.weather.com.cn/alarm/grepalarm_cn.php?_={get_time_stamp()}'
res = requests.get(url, headers=get_headers_init_referer("https://www.weather.com.cn/"))
content = res.content.decode('utf-8')[14:-1]
data = json.loads(content)
time.sleep(1)
for item in data['data']:
    print(item)
    detail_url = f'https://product.weather.com.cn/alarm/webdata/{item[1]}?_={get_time_stamp()}'
    detail_res = requests.get(detail_url, headers=get_headers_init_referer('https://www.weather.com.cn/'))
    detail_data = json.loads(detail_res.content.decode('utf-8')[14:])
    print(detail_data)

    break


